<template>
	<div>
		<!-- 面包屑导航 -->
		<el-breadcrumb separator-class="el-icon-arrow-right">
			<el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
			<el-breadcrumb-item>权限管理</el-breadcrumb-item>
			<el-breadcrumb-item>权限列表</el-breadcrumb-item>
		</el-breadcrumb>
		
		<el-card>
			<el-table :data="rightsList" border stripe>
				<el-table-column type="index" label="#"></el-table-column>
				<el-table-column prop="authName" label="权限名称"></el-table-column>
				<el-table-column prop="path" label="路径"></el-table-column>
				<el-table-column label="权限等级">
					<template slot-scope="scope">
						<el-tag :type="levelColor[scope.row.level]">{{level[scope.row.level]}}</el-tag>
					</template>
				</el-table-column>
			</el-table>
		</el-card>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				// 权限列表
				rightsList: [],
				// 等级权限
				level: {
					0 : "等级一",
					1 : "等级二",
					2 : "等级三"
				},
				// 权限等级颜色
				levelColor: {
					0 : "primary",
					1 : "success",
					2 : "danger"
				}
			}
		},
		created() {
			this.getRightsList()
		},
		methods: {
			// 获取权限列表函数
			async	getRightsList() {
				// 接收数据
				const data = await	this.$http.get('rights/list')
				// 判断状态码
				if(data.data.meta.status !== 200) {
					return this.$message.error('获取权限列表失败！')
				}
				// 获取成功之下以下代码
				this.rightsList = data.data.data
			},
		}
	}
</script>

<style lang="less" scoped>
	
</style>
